using System;
using System.Collections.Generic;
using Com.ContentRendering.Api.RenderEngine;
using ContentRenderingApi.Node;

namespace ContentRenderingApi.Envelope
{
    /// <summary/>
    internal class InputNodeEnvelope : InputNodeInterface
    {
        private AbstractNode _node;

        /// <summary/>
        internal InputNodeEnvelope(AbstractNode node)
        {
            this._node = node;
        }

        /// <summary/>
        bool InputNodeInterface.IsContent()
        {
            return this._node.IsContent();
        }

        /// <summary/>
        bool InputNodeInterface.IsOutputTag()
        {
            return this._node.IsOutputTag();
        }

        /// <summary/>
        bool InputNodeInterface.IsSubstitutionTag()
        {
            return this._node.IsSubstitutionTag();
        }

        /// <summary/>
        bool InputNodeInterface.IsTransparentTag()
        {
            return this._node.IsTransparentTag();
        }

        /// <summary/>
        bool InputNodeInterface.IsIfTag()
        {
            return this._node.IsIfTag();
        }

        /// <summary/>
        bool InputNodeInterface.IsIfNotTag()
        {
            return this._node.IsIfNotTag();
        }

        /// <summary/>
        bool InputNodeInterface.IsParentTag()
        {
            return this._node.IsParentTag();
        }

        /// <summary/>
        bool InputNodeInterface.IsRootTag()
        {
            return this._node.IsRootTag();
        }

        /// <summary/>
        bool InputNodeInterface.IsChildTag()
        {
            return this._node.IsChildTag();
        }

        /// <summary/>
        string InputNodeInterface.Name
        {
            get { return this._node.Name; }
        }

        /// <summary/>
        int InputNodeInterface.ParentLevel
        {
            get { return this._node.ParentLevel; }
        }

        /// <summary/>
        string InputNodeInterface.Content
        {
            get { return this._node.Content; }
        }

        /// <summary/>
        IEnumerator<InputNodeInterface> InputNodeInterface.FetchChildNodes()
        {
            IEnumerator<AbstractNode> enumerator = this._node.FetchChildNodes();
            List<InputNodeInterface> inputNodes = new List<InputNodeInterface>();

            // move each element to the nodes container
            while(enumerator.MoveNext())
            {
                inputNodes.Add(new InputNodeEnvelope(enumerator.Current));
            }

            return inputNodes.GetEnumerator();
        }
    }
}
